{include file="public/header" /}
<link rel="stylesheet" href="/static/index/css/page/payment.css">
<body>
<div class="build-navbar" data-title="支付订单"></div>
<div class="main">
    <div class="top flex flex-col justify-center items-center">
        <div class="desc">实付金额</div>
        <div class="amount front">{$info.real_amount}</div>
        <!--        <div class="desc">支付剩余时间 14:25</div>-->
    </div>
    <div class="pay">
        {foreach name="method" item="vo" key='key'}
        <div class="pay-item flex items-center justify-between {if !$key}lay-this{/if}"
             data-is="{$vo.is_pay_password}"
             data-val="{$vo.pay_way}" lay-change="pay_way">
            <div class="pay-name flex items-center">
                <img src="{$vo.icon}" alt="" class="pay-icon">
                <div class="title">{$vo.title}</div>
            </div>
            <img src="/static/index/images/{$key?'not-':''}check.png" alt="" class="pay-check">
        </div>
        {/foreach}
    </div>
</div>
<div class="btn theme-btn fixed-btn" lay-click="confirm">确认支付</div>

</body>
{include file="public/footer"/}
<script>
    layui.use(['methods'], function () {
        var m = layui.methods, a = layui.jquery, ly = layui.layer;
        m.event.change('pay_way', function (data, that) {
            a('.pay-check').attr('src', '/static/index/images/not-check.png');
            a(that).find('.pay-check').attr('src', '/static/index/images/check.png');
        });

        m.event.click('confirm', function () {
            var pay_way = a('.lay-this').attr('data-val'), is = a('.lay-this').attr('data-is');
            if (!pay_way) {
                ly.msg('请选择支付方式');
                return false;
            }
            return parseInt(is)
                ? m.popup.payPassword(function (password) {
                    payment(pay_way, password)
                })
                : payment(pay_way);

        });

        function payment(pay_way, pay_password, index) {
            return m.fetchPostThrottle('{:url("order/confirmPayment")}', {
                id: '{$info.id}',
                pay_way: pay_way,
                pay_password: pay_password
            }, function (d) {
                switch (d.code) {
                    case 1:
                        location.href = d.url;
                        break;
                    default:
                        a('.pay_password').val('')
                        ly.msg(d.msg);
                }

            })
        }

    });
</script>
</html>